<?php
namespace Face\Controller;
class ListController extends CommonController {
    /*列表首页*/
    public function index()
    {
        $id = i('get.id');
        $count      = M('goods')->where(['goods_shangjia'=>1,'goods_type'=>$id])->count();// 查询满足要求的总记录数
        if($count==0){
            $this->redirect('Face/List/kong');
        }
        $Page       = new \Think\Page($count,20);// 实例化分页类 传入总记录数和每页显示的记录数(10)
        $Page->setConfig('theme',"%HEADER% %FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END%");
        $show       = $Page->show();// 分页显示输出

        // 进行分页数据查询 注意limit方法的参数要使用Page类的属性
        $list = M('goods')->where(['goods_shangjia'=>1,'goods_type'=>$id])->order('id desc')->limit($Page->firstRow.','.$Page->listRows)->select();

        $this->assign(['page'=>$show,'data'=>$list]);

        $this->display();
    }

    public function kong()
    {
        $this->display();
    }
}